#pragma once

// common macro
#ifndef SAVE_RELEASE
#define SAFE_RELEASE(x) if(x) (x)->Release();
#endif

// math define
extern const float EPSILON;
extern const float PI;
extern const float PI2;
extern const float PIBY2;

void string2wstring(const std::string& str, std::wstring& out);

void wstring2String(const std::wstring& ws, std::string& out);

/**
@remark convert degree -> radius
*/
float rad2Deg(float rad);

/**
@remark convert radius -> degree
*/
float deg2Rad(float deg);

/**
 @remark return the value of LOGbase(x)
*/
template<class T>
T logbase(T x, T base) 
{
	return (T)(log((double)x)/log((double)base));
}

static const vec4f XAXIS = vec4f(1, 0, 0, 1);
static const vec4f YAXIS = vec4f(0, 1, 0, 1);
static const vec4f ZAXIS = vec4f(0, 0, 1, 1);
static const mat4f IDENTITY_MATRIX;

// returns right-handed coordinate system perspective matrix
mat4f getProjectionMatrixRH(float halfAngleInDegree, float ratio, float znear, float zfar);